package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.MakerSaveList;
import com.ruoyi.service.IMakerSaveListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 物料字段列表Controller
 * 
 * @author 牢博
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/makerSaveList/list")
public class MakerSaveListController extends BaseController
{
    @Autowired
    private IMakerSaveListService makerSaveListService;

    /**
     * 查询物料字段列表列表
     */
    @PreAuthorize("@ss.hasPermi('makerSaveList:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(MakerSaveList makerSaveList)
    {
        startPage();
        List<MakerSaveList> list = makerSaveListService.selectMakerSaveListList(makerSaveList);
        return getDataTable(list);
    }

    /**
     * 导出物料字段列表列表
     */
    @PreAuthorize("@ss.hasPermi('makerSaveList:list:export')")
    @Log(title = "物料字段列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MakerSaveList makerSaveList)
    {
        List<MakerSaveList> list = makerSaveListService.selectMakerSaveListList(makerSaveList);
        ExcelUtil<MakerSaveList> util = new ExcelUtil<MakerSaveList>(MakerSaveList.class);
        util.exportExcel(response, list, "物料字段列表数据");
    }

    /**
     * 获取物料字段列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('makerSaveList:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(makerSaveListService.selectMakerSaveListById(id));
    }

    /**
     * 新增物料字段列表
     */
    @PreAuthorize("@ss.hasPermi('makerSaveList:list:add')")
    @Log(title = "物料字段列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MakerSaveList makerSaveList)
    {
        return toAjax(makerSaveListService.insertMakerSaveList(makerSaveList));
    }

    /**
     * 修改物料字段列表
     */
    @PreAuthorize("@ss.hasPermi('makerSaveList:list:edit')")
    @Log(title = "物料字段列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MakerSaveList makerSaveList)
    {
        return toAjax(makerSaveListService.updateMakerSaveList(makerSaveList));
    }

    /**
     * 删除物料字段列表
     */
    @PreAuthorize("@ss.hasPermi('makerSaveList:list:remove')")
    @Log(title = "物料字段列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(makerSaveListService.deleteMakerSaveListByIds(ids));
    }
}
